package com.sss.controller;

import com.sss.entity.WmStorageLocation;
import com.sss.service.WmStorageLocationService;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.sss.util.R;
/**
 * 库区表(WmStorageLocation)表控制层
 *
 * @author makejava
 * @since 2023-12-14 16:55:32
 */
@RestController
@RequestMapping("/api/wmStorageLocation")
public class WmStorageLocationController {
    /**
     * 服务对象
     */
    @Autowired
    private WmStorageLocationService wmStorageLocationService;

    /**
     * 分页查询
     *
     * @return 查询结果
     */
    @GetMapping("/list/page")
    public R queryByPage(Long pageNum) {
        return R.ok(this.wmStorageLocationService.queryByPage(pageNum));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/{id}")
    public R queryById(@PathVariable("id") Long id) {
        return R.ok(this.wmStorageLocationService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param wmStorageLocation 实体
     * @return 新增结果
     */
    @PostMapping("/save")
    public R add(@RequestBody WmStorageLocation wmStorageLocation) {
        this.wmStorageLocationService.insert(wmStorageLocation);
        return R.ok();
    }

    /**
     * 编辑数据
     *
     * @param wmStorageLocation 实体
     * @return 编辑结果
     */
    @PostMapping("/edit")
    public R edit(@RequestBody WmStorageLocation wmStorageLocation) {
        return R.ok(this.wmStorageLocationService.update(wmStorageLocation));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @GetMapping("/del")
    public R deleteById(Long id) {
        return R.ok(this.wmStorageLocationService.deleteById(id));
    }

}

